package views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.zx.theline.R;

import GsonBean.ZbyjhBean;


/**
 * Created by Ren on 2017/7/28.
 */

public class ZbyjhView extends RelativeLayout {
    LinearLayout view;
    LinearLayout tablelayout;

    ZbyjhBean.RowsBean mZbyjhBean;


    int position;

    //月计划号
    TextView yjhh;
    //施工日期
    TextView sgrq;
    //类别
    TextView lb;
    //线名
    TextView xm;
    //行别
    TextView hb;
    //施工地点
    TextView sgdd;
    //施工项目
    TextView sgxm;
    //施工内容
    TextView sgnr;
    //施工机械
    TextView sgjx;
    //B类防护
    TextView blfh;
    //施工单位
    TextView sgdw;
    //状态
    TextView zt;
    //操作按钮图片
    TextView mImageView;
    //B类防御layout
    LinearLayout layout_blfh;


    public ZbyjhView(Context context) {
        super(context);
        initView();
        initDate();
        initListen();
    }

    public ZbyjhView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
        initDate();
        initListen();
    }

    public ZbyjhView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView();
        initDate();
        initListen();
    }


    private void initView() {
        view = (LinearLayout) inflate(getContext(), R.layout.zbyjhview, null);
        addView(view);
        yjhh = (TextView) findViewById(R.id.yjhh);
        sgrq = (TextView) findViewById(R.id.sgrq);
        lb = (TextView) findViewById(R.id.lb);
        layout_blfh = (LinearLayout) findViewById(R.id.layout_blfh);
        xm = (TextView) findViewById(R.id.xm);
        hb = (TextView) findViewById(R.id.hb);
        sgdd = (TextView) findViewById(R.id.sgdd);
        sgxm = (TextView) findViewById(R.id.sgxm);
        sgnr = (TextView) findViewById(R.id.sgnr);
        sgjx = (TextView) findViewById(R.id.sgjx);
        blfh = (TextView) findViewById(R.id.blfh);
        sgdw = (TextView) findViewById(R.id.sgdw);
        mImageView = (TextView) findViewById(R.id.mImageView);
        tablelayout = (LinearLayout) findViewById(R.id.tablelayout);
    }

    private void initDate() {

    }

    private void initListen() {

        mImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
    }

    public void setDate(ZbyjhBean.RowsBean mZbyjhBean) {
        this.mZbyjhBean = mZbyjhBean;
        yjhh.setText(mZbyjhBean.getBh());
        sgrq.setText(mZbyjhBean.getExsgrq());
        lb.setText(mZbyjhBean.getLb() + "类");
        if (mZbyjhBean.getLb().equals("B")) {
            lb.setTextColor(getResources().getColor(R.color.colorTextB));
        } else if (mZbyjhBean.getLb().equals("C")) {
            lb.setTextColor(getResources().getColor(R.color.colorTextC));
        }
        xm.setText(mZbyjhBean.getXlmc());
        hb.setText(mZbyjhBean.getXbmc());
        sgdd.setText(mZbyjhBean.getSgdd());
        sgxm.setText(mZbyjhBean.getXmmc());
        sgnr.setText(mZbyjhBean.getNrmc());
        sgjx.setText(mZbyjhBean.getJxmc());
        blfh.setText(mZbyjhBean.getFhcsmc());
        sgdw.setText(mZbyjhBean.getSgdwmc());

    }


    public void showLayoutProtectB() {
        layout_blfh.setVisibility(VISIBLE);
    }

    public void hideLayoutProtectB() {
        layout_blfh.setVisibility(GONE);
    }

}
